{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "bdc97164-cc27-49ff-8efe-415ffa9d6868",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'Account' object has no attribute '__balance__'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[2], line 22\u001b[0m\n\u001b[0;32m     20\u001b[0m childCard\u001b[38;5;241m.\u001b[39mpaid(\u001b[38;5;241m10\u001b[39m)\n\u001b[0;32m     21\u001b[0m account\u001b[38;5;241m.\u001b[39mpay(\u001b[38;5;241m30\u001b[39m)\n\u001b[1;32m---> 22\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[43maccount\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m__balance__\u001b[49m())\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'Account' object has no attribute '__balance__'"
     ]
    }
   ],
   "source": [
    "class Account:\n",
    "    _balance = 0\n",
    "\n",
    "    def __init__(self, balance):\n",
    "        self._balance = balance\n",
    "\n",
    "    def paid(self,amount):\n",
    "        self._balance += amount\n",
    "\n",
    "    def pay(self,amount):\n",
    "        self._balance -= amount\n",
    "\n",
    "    def balance(self):\n",
    "        return self._balance\n",
    "account = Account(100)\n",
    "addOnCard = account\n",
    "childCard = account\n",
    "account.paid(10)\n",
    "addOnCard.paid(10)\n",
    "childCard.paid(10)\n",
    "account.pay(30)\n",
    "print(account.__balance__())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "72f538d0-5abf-49b9-b60a-0da4cbc714a1",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
